//-----------------------------------------------------------------------------
//
// FifteenPuzzle
//
// Eugene Magdel and Joshua Jung
//
// 2011 for University of Illinois at Chicago CS340 w/ Professor Troy
//
//-----------------------------------------------------------------------------
#include <iostream>
#include "block.h"
#include "stdlib.h"
#include <QGraphicsPixmapItem>

#ifndef GRID_H
#define GRID_H

using namespace std;
class Grid{
    enum direction {RIGHT, DOWN, LEFT, UP};
    private:
        //Stores blocks and puts them into queue
        int rows_count;
        Block *current;

        void push_back(Block*);
        //Returns block at given index
        Block& block_at(int=0);

    public:
        Grid(int);

        void move(Block*);
        bool top_row(int);
        bool bottom_row(int);
        bool left_row(int);
        bool right_row(int);
        void swap(Block *, Block *);
        Block * forward_pointer(Block *, int);
        void print();
        void sort();
        int size();
        bool solved();
        bool solvable();
        void mix();
        int rows();
        void solve();
        void initialize_tiles(QGraphicsScene*);
        QGraphicsScene *scene;
        Block *first;
        void draw_tiles();
        void click(int,int);
};
#endif
